<template>
  <div class="resource">
    <el-card shadow="hover">
      <div>
        <i class="el-icon-search" />
        <span>筛选搜索</span>
        <el-button
          icon="el-icon-search"
          type="primary"
          size="mini"
          @click="search"
          style="margin-left: 20px;"
        >
          搜索
        </el-button>
        <el-button
          icon="el-icon-refresh-right"
          size="mini"
          plain
          @click="cancelData"
        >
          重置
        </el-button>
      </div>
      <el-row :gutter="20" style="margin-top: 20px">
        <el-form
          ref="params"
          :model="params"
          label-width="130px"
          size="small"
          class="searchForm"
        >
          <el-col :span="6">
            <el-form-item label="咨询公司:" prop="companyName">
              <el-input
                v-model="params.companyName"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单编号:" prop="orderSn">
              <el-input
                v-model="params.orderSn"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单状态:" prop="state">
              <el-select
                v-model="params.state"
                placeholder="请选择"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in stateOptions"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="对接人:" prop="dockingPeople" v-if="!openFlag">
              <el-input
                v-model="params.dockingPeople"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              label="联系电话:"
              prop="dockingPhone"
              v-if="!openFlag"
            >
              <el-input
                v-model="params.dockingPhone"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证书名称:" prop="certificateName">
              <el-input
                v-model="params.certificateName"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="电子证书出证日期:" prop="edHisDate">
              <el-date-picker
                v-model="params.edHisDate"
                type="date"
                placeholder="选择日期"
                @change="search"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="纸质证书出证日期:" prop="paperHisDate">
              <el-date-picker
                v-model="params.paperHisDate"
                type="date"
                placeholder="选择日期"
                @change="search"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="咨询服务:" prop="state">
              <el-select
                v-model="params.consult"
                filterable
                placeholder="请选择"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in consultList"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
    </el-card>

    <div class="container">
      <div class="handle-box">
        <!-- <el-button
          size="small"
          type="primary"
          icon="el-icon-plus"
          @click="handleAdd"
          class="mr10"
          >新增</el-button
        > -->
        <!-- <el-button
          type="danger"
          icon="el-icon-delete"
          class="handle-del mr10"
          size="small"
          :disabled="multiple"
          @click="handleDelete"
          >批量删除</el-button
        > -->
      </div>

      <el-table
        v-loading="loading"
        :data="tableData"
        border
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column
          type="selection"
          width="50"
          align="center"
        ></el-table-column> -->
         <!-- 二级菜单 -->
         <el-table-column type="expand">
            <template slot-scope="props">
              <h3>订单列表</h3>
              <el-table
                :data="props.row.certificateOrderList"
                border
                header-cell-style="color: #515a6e;background:#f8f8f9"
                style="width: 100%">
                <!-- <el-table-column
                    type="selection"
                    width="50"
                    align="center"
                  ></el-table-column> -->
                <el-table-column
                  prop="orderSn"
                  align="center"
                  label="订单编号"
                  width="width">
                  <template slot-scope="scope">
                  <span
                    class="blue"
                    style="text-decoration: underline; margin-left: 5px"
                    @click="handleEdit(scope.$index, scope.row,2)"
                    >{{ scope.row.orderSn }}</span
                  >
                </template>
                </el-table-column>
                <el-table-column
                  prop="certificateName"
                  label="证书名称"
                  align="center"
                  min-width="150"
                  :show-overflow-tooltip="true"
                  
                ></el-table-column>
                <el-table-column prop="address" align="center" width="120" show-overflow-tooltip label="客户地址"></el-table-column>
                <el-table-column prop="actualAddress" align="center" width="120" show-overflow-tooltip label="办公地址"></el-table-column>
                <el-table-column prop="region" align="center" width="120" show-overflow-tooltip label="经营范围"></el-table-column>
                <el-table-column label="规格说明" align="center" min-width="200" >
                  <template slot-scope="scope">
                    {{ scope.row.specName }}
                  </template>
                </el-table-column>
                 <el-table-column label="是否咨询" align="center" width="150">
                  <template slot-scope="scope">
                    {{status_consult(scope.row.consult)}}
                  </template>
                </el-table-column>
                <el-table-column label="咨询费是否支付" align="center" width="150">
                  <template slot-scope="scope">
                    <span v-if="scope.row.consultState=='0'">未支付</span>
                    <span v-else style="color:blue">已支付</span>
                  </template>
                </el-table-column>
                <el-table-column
          prop="dockingPeople"
          label="对接人"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="dockingPhone"
          label="联系电话"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column label="营业执照" min-width="150" align="center">
          <template slot-scope="scope">
            <viewer >
              <img
                v-if="scope.row.businessLicense != null"
                class="study_pic"
                :src="showUrl + JSON.parse(scope.row.businessLicense)[0]"
                alt=""
              />
            </viewer>
          </template>
        </el-table-column>
        <el-table-column label="出证日期(电子)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.edHisDate) }}
          </template>
        </el-table-column>
        <el-table-column label="出证日期(纸质)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.paperHisDate) }}
          </template>
        </el-table-column>
        <el-table-column label="订单状态" align="center" min-width="150">
          <template slot-scope="scope">
            <span>{{ status(scope.row.state) }}</span>
          </template>
        </el-table-column>
            <el-table-column
          label="咨询老师"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            {{ scope.row.teacherName }}
          </template>
        </el-table-column>
        <el-table-column
          prop="wuLiu"
          label="物流单号"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="remarks"
          label="备注说明"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="创建时间" align="center" min-width="155">
          <template slot-scope="scope">{{
            formatT(scope.row.createTime)
          }}</template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="handlePass(scope.row)"
              v-if="scope.row.state == 3"
            >
              通过
            </el-button>
            <el-button
              type="text"
              @click="handleReturn(scope.row)"
              v-if="scope.row.state == 3"
            >
              拒绝
            </el-button>
             <el-button
              type="text"
              @click="handleEdit(scope.$index, scope.row,2)"
              >查看</el-button
            >
            <el-button
              type="text"
              @click="handleProcess(scope.row)"
            >流程
            </el-button>
            <el-button
              type="text"
              @click="handleEditOrder(scope.$index, scope.row)"
              v-hasPermi="['update']"
              v-if="scope.row.state == 4 || scope.row.state == 5 || scope.row.state == 6 || scope.row.state == 7"
              >编辑</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
        </el-table-column>
        <!-- <el-table-column
          prop="orderSn"
          label="订单编号"
          align="center"
          min-width="200"
        
        ></el-table-column> -->
        <!-- <el-table-column
          prop="certificateName"
          label="证书名称"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        
        ></el-table-column>
        <el-table-column label="规格说明" align="center" min-width="180">
          <template slot-scope="scope">
            {{ scope.row.specName }}
          </template>
        </el-table-column> -->
        <el-table-column label="是否咨询" align="center" width="150">
          <template slot-scope="scope">
            {{status_consult(scope.row.consult)}}
          </template>
        </el-table-column>
        <!-- <el-table-column
          label="咨询公司"
          width="150"
          align="center"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.companyName }}</span>
          </template>
        </el-table-column> -->
        <el-table-column
          prop="dockingPeople"
          label="对接人"
          align="center"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="sysName"
          label="业务人员"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="dockingPhone"
          label="联系电话"
          align="center"
          width="150"
        ></el-table-column>
        <el-table-column
          label="营业执照"
          min-width="150"
          align="center"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <viewer >
              <img
                v-if="scope.row.businessLicense != null"
                class="study_pic"
                :src="showUrl + JSON.parse(scope.row.businessLicense)[0]"
                alt=""
              />
            </viewer>
          </template>
        </el-table-column>
        <el-table-column label="出证日期(电子)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.edHisDate) }}
          </template>
        </el-table-column>
        <el-table-column label="出证日期(纸质)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.paperHisDate) }}
          </template>
        </el-table-column>
        <!-- <el-table-column label="订单状态" align="center" width="150">
          <template slot-scope="scope">
            <span>{{ status(scope.row.state) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="price"
          label="证书金额"
          align="center"
          width="100"
        ></el-table-column>
        <el-table-column
          prop="orgPrice"
          label="机构金额"
          align="center"
          width="100"
        ></el-table-column>
        <el-table-column
          label="咨询老师"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            {{ scope.row.teacherName }}
          </template>
        </el-table-column> -->
        <el-table-column
          prop="remarks"
          label="备注说明"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="创建时间" align="center" min-width="160">
          <template slot-scope="scope">{{
            formatT(scope.row.createTime)
          }}</template>
        </el-table-column>
        <el-table-column label="操作" width="170" align="center" >
          <template slot-scope="scope">
            <el-button
              type="text"
              icon="el-icon-edit-outline"
              @click="handleEdit(scope.$index, scope.row,1)"
              >查看</el-button
            >
            <!-- <el-button
              type="danger"
              size="small"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              >删除</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>
      <!-- </el-card> -->
      <div class="pagination">
        <pagination
          v-show="pageTotal > 0"
          :total="pageTotal"
          :page.sync="params.pageNum"
          :limit.sync="params.pageSize"
          @pagination="getData00"
        />
      </div>
    </div>
    <!-- 查看信息框 -->
    <el-dialog :title="title666" :visible.sync="dialogVisible" width="800px">
      <el-form
        ref="formData"
        :model="formData"
        label-width="130px"
        size="small"
        class="form-box"
      >
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="订单编号:" prop="orderSn">
              <el-input v-model="formData.orderSn" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="咨询公司:" prop="companyName">
              <el-input v-model="formData.companyName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col v-if="ind == 2" :span="12">
            <el-form-item label="证书名称:" prop="certificateName">
              <el-input v-model="formData.certificateName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格:" prop="specName">
              <el-input v-model="formData.specName" disabled></el-input>
              <!-- <span>{{formData.specName}}</span> -->
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="对接人:" prop="dockingPeople">
              <el-input v-model="formData.dockingPeople" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="对接人号码:" prop="dockingPhone">
              <el-input v-model="formData.dockingPhone" disabled></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="电子证书出证时间" prop="edHisDate">
              <el-date-picker
                v-model="formData.edHisDate"
                type="date"
                placeholder="选择出证日期"
                value-format="yyyy-MM-dd"
                disabled
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纸质证书出证时间" prop="paperHisDate">
              <el-date-picker
                v-model="formData.paperHisDate"
                type="date"
                placeholder="选择出证日期"
                value-format="yyyy-MM-dd"
                disabled
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="营业执照:" prop="businessLicense">
              <div v-for="item in formData.businessLicense" class="avatar" :key="item">
                <viewer>
                  <img :src="showUrl + item" alt="" width="200" height="180"/>
                </viewer>
              </div>
              <!-- <img :src="imgUrl + formData.businessLicense" class="avatar" /> -->
            </el-form-item>
          </el-col>
          <el-col v-if="ind == 2"  :span="12">
            <el-form-item label="证书金额:" prop="price">
              <el-input v-model="formData.price" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col v-if="ind == 2"  :span="12">
            <el-form-item label="机构金额:" prop="orgPrice">
              <el-input v-model="formData.orgPrice" disabled></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="24">
            <el-form-item label="备注">
              <el-input
                :rows="6"
                type="textarea"
                v-model="formData.remarks"
              ></el-input>
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small">取消</el-button>
        <el-button @click="submitForm()" type="primary" size="small"
          >确定</el-button
        >
      </span> -->
    </el-dialog>

    <!-- 平台审批驳回 -->
    <el-dialog title="审批" :visible.sync="checkVisible" width="40%">
      <el-form
        ref="checkForm"
        :model="checkForm"
        label-width="120px"
        :rules="checkRules"
      >
        <el-form-item label="审批驳回原因：" prop="remarks">
          <el-input v-model="checkForm.remarks"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelCheck">取 消</el-button>
        <el-button type="primary" @click="sumitCheck">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 平台审核通过并选择机构、提交成交价 -->
    <el-dialog title="审批通过" :visible.sync="selectJigouVisible" width="40%">
      <el-form
        ref="selectJigouForm"
        :model="selectJigouForm"
        label-width="130px"
        :rules="selectJigouRules"
      >
        <el-form-item label="机构选择" prop="orgId">
          <el-select
            v-model="selectJigouForm.orgId"
            filterable
            placeholder="请选择机构"
            style="width:360px"
          >
            <el-option
              v-for="item in companyLists"
              :key="item.id"
              :label="item.authorityName"
              :value="item.id"
            >
            <span style="float: left">{{ item.authorityName }}</span>
            <span style="float: right;">{{ item.phone }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="咨询老师选择" prop="teacherId">
          <el-select
            v-model="selectJigouForm.teacherId"
            filterable
            placeholder="请选择咨询老师"
            clearable
            style="width:360px"
          >
            <el-option
              v-for="item in teacherLists"
              :key="item.userId"
              :label="item.userName"
              :value="item.userId"
            >
            <span style="float: left">{{ item.userName }}</span>
            <span style="float: right;">{{ item.phonenumber }}</span>
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel_teacher">取 消</el-button>
        <el-button type="primary" @click="submit_teacher">确 定</el-button>
      </span>
    </el-dialog>

 <!-- 流程查看 -->
    <el-dialog title="流程查看" :visible.sync="dialogVisible1010" width="800px">
      <div class="progress_box" v-for="(item, index) in steps" :key="index">
        <div class="left_c" v-if="item.finish == 1">已完成</div>
        <div class="left" v-if="item.finish == 0">处理中</div>
        <div class="center">
          <i
            class="el-icon-star-on"
            style="color:#000"
            v-if="item.finish == 1"
          ></i>
          <i
            class="el-icon-star-on"
            style="color:#888"
            v-if="item.finish == 0"
          ></i>
        </div>
        <!-- <div class="right_c"> -->
				<div :class="[item.finish==1?'right_c':'right']">
          <div class="top88" v-if="item.finish == 1">
            <span class="time88">{{ item.updateTime }}</span>
            <span
              class="loading88"
              v-if="item.accessory && item.flowSerial != 18"
              @click="downLoadPaper(item.accessory)"
              >下载附件</span
            >
            <span
              class="loading88"
              v-if="item.accessory && item.flowSerial == 18"
              @click="ViewCert(item.accessory)"
              >预览证书</span
            >
          </div>
          <div class="title88">[{{ item.flowName }}]</div>
          <div class="desc88" v-if="item.finish == 1 && item.context">
            {{ item.context }}
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 预览证书 -->
    <el-dialog title="证书预览" :visible.sync="certVisible" width="700px">
      <div v-for="(item,index) in cert_view" :key="index" class="father_box">
        <img :src="showUrl + item.url" width="200" height="240"/>
        <div class="son_box">水印证书</div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { companyList } from "@/api/jigou_company/jigou_company";
import {
  orderReceive_List,
  updateOrder,
  checkTeacher,
  updateProcess,
  fetchOrder_pt,
  queryProcess
} from "@/api/order/orderReceiveAds";
import { certificateList } from "@/api/certificate/certificateAds";
import { teacherList, checkTeacherList } from "@/api/teacher/teacherAds";
import { getToken } from "@/utils/auth";
export default {
  components: {},
  props: [],
  data() {
    return {
      cateList2: [],
      ind:0,
      // 非多个禁用
      multiple: true,
      //删除
      ids: [],
      headers: { Authorization: "Bearer " + getToken() },
      upImage: process.env.VUE_APP_BASE_API,
      title666: "",
      rules2: {
        phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
        companyName: [
          { required: true, message: "请输入公司名称", trigger: "blur" }
        ],
        linkman: [
          { required: true, message: "请输入联系人名称", trigger: "blur" }
        ],
        businessLicense: [
          { required: true, message: "请上传图片", trigger: "blur" }
        ]
      },
      passRules: {
        teacherId: [{ required: true, message: "请选择老师", trigger: "blur" }]
      },
      input: "",
      openFlag: true,
      loading: true,
      // 编辑框里用于比对的流程
      steps100: [],
      steps: [],
      dialogVisible1010: false,
      //数据
      tableData: [],
      cert_view:[],
      params: {
        pageNum: 1,
        pageSize: 10,
        state: 3,
        position: 1
      },
      consultList: [
        { id: 1,title: '需咨询' },
        { id: 2,title: '不咨询' }
      ],
      stateOptions: [
        { id: 3, title: "平台待接单" },
        { id: 4, title: "处理中" },
        { id: 8, title: "已拒绝" }
      ],
      pageTotal: 0,
      dialogVisible: false, // 是否展示编辑页面
      certVisible: false,
      // 新增/编辑数据
      formData: {
        businessLicense: ""
      },
      customer: {
        customerId: ""
      },
      paramsFlag: 0,
      editFlags: false,

      checkVisible: false,
      checkForm: {
        remarks: ""
      },
      checkRules: {
        remarks: [
          { required: true, message: "审批驳回原因不能为空", trigger: "blur" }
        ]
      },
      teacherLists: [], // 咨询老师列表
      companyLists: [], // 机构列表

      selectJigouVisible: false,
      selectJigouForm: {},
      selectJigouRules: {
        orgId: [{ required: true, message: "请选择机构", trigger: "blur" }],
        teacherId: [{ required: true, message: "请选择咨询老师", trigger: "blur" }],
        orgPrice: [{ required: true, message: "请填写订单成交价", trigger: "blur"}]
      }
    };
  },
  computed: {},
  created() {
    this.getJigouList();
    this.getData00();
    this.getTeacherData();
  },
  mounted() {},
  watch: {},
  methods: {
    // 点击预览证书
    ViewCert(val){
      this.cert_view = JSON.parse(val);
      this.certVisible = true;
    },
    // 点击查看流程
    handleProcess(row) {
      this.steps = [];
      queryProcess({
        orderId: row.id
      }).then(res => {
        if (res.code == 200) {
          res.rows.forEach((item, index) => {
            if (item.flowSerial > 7) {
              this.steps.push(item);
            }
          });
          this.dialogVisible1010 = true;
        }
      });
    },
    // 触发流程
    process(id,flowSerial,context,accessory) {
      updateProcess({
        orderId: id,
        flowSerial: flowSerial,
        context: context,
        accessory: accessory,
        finish: 1,
        flowList:[{
          orderId: id,
          flowSerial: flowSerial,
          context: context,
          accessory: accessory,
          finish: 1,
        }],
      }).then(res => {
        if (res.code == 200) {
          this.$message.success("操作成功");
          this.getData00();
        }
      });
    },
    // 点击下载附件
    downLoadPaper(val) {
      let value = JSON.parse(val);
      let that = this;
      value.forEach(item => {
        this.downloadFile(item.url);
      });
    },
    downloadFile(url) {
      const iframe = document.createElement("iframe");
      iframe.style.display = "none"; // 防止影响页面
      iframe.style.height = 0; // 防止影响页面
      iframe.src = this.showUrl + url;
      document.body.appendChild(iframe); // 这一行必须，iframe挂在到dom树上才会发请求
      // 1分钟之后删除（onload方法对于下载链接不起作用，就先抠脚一下吧）
      setTimeout(() => {
        iframe.remove();
      }, 1 * 60 * 1000);
    },
    getTeacherData(){
      checkTeacherList({
        pageNum: 1,
        pageSize: 1000
      }).then(res => {
        this.teacherLists = res.data;
      })
    },
    getJigouList() {
      companyList({
        pageNum: 1,
        pageSize: 1000,
        type:1
      }).then(res => {
        if (res.code == 200) {
          this.companyLists = res.rows;
        }
      });
    },
    cancel_teacher() {
      this.selectJigouVisible = false;
      this.selectJigouForm = {};
      this.getData00();
    },
    submit_teacher() {
      this.$refs["selectJigouForm"].validate(valid => {
        if (valid) {
          this.selectJigouForm.state = 4;
          updateOrder(this.selectJigouForm).then(res => {
            if (res.code == 200) {
              // if(this.selectJigouForm.consult == 1){
                checkTeacher({
                  teacherId: this.selectJigouForm.teacherId,
                  orderId: this.selectJigouForm.id
                }).then(res => { 
                  if(res.code == 200){
                    this.process(this.selectJigouForm.id,3,'','');
                    this.process(this.selectJigouForm.id,4,'','');
                    this.selectJigouVisible = false;
                  }
                })
              // }
            }
          });
        }
      });
    },
    //获取数据
    getData00() {
      fetchOrder_pt(this.params).then(res => {
        if (res.code == 200) {
          this.tableData = res.rows;
          this.pageTotal = res.total;
          this.loading = false;
        }
      });
    },
    // 审批通过
    handlePass(row) {
      this.selectJigouForm = {};
      this.selectJigouForm = row;
      this.selectJigouVisible = true;
    },
    // 审批拒绝
    handleReturn(row) {
      this.checkForm = row;
      this.checkVisible = true;
      this.checkForm.remarks = "";
    },
    // 驳回提交
    sumitCheck() {
      this.$refs["checkForm"].validate(valid => {
        if (valid) {
          this.checkForm.state = 8;
          updateOrder(this.checkForm).then(res => {
            if (res.code == 200) {
              this.$message.success("审批拒绝成功");
              this.getData00();
              this.checkVisible = false;
            } else {
              this.$message.error("拒绝失败");
              this.checkVisible = false;
            }
          });
        }
      });
    },
    cancelCheck() {
      this.checkVisible = false;
      this.checkForm.remarks = "";
    },
    // 查询证书类别列表
    getCateList() {
      this.loading = true;
      certificateList({
        pageNum: 1,
        pageSize: 9999
      }).then(res => {
        this.loading = false;
        if (res.code == 200) {
          this.cateList2 = res.rows;
          // this.cateList = res.rows;
        } else {
          this.msgError("查询失败！");
        }
      });
    },
    querySearch(queryString, cb) {
      // console.log(queryString, this.cateList2);
      var restaurants = this.cateList2;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return restaurant => {
        return (
          restaurant.categoryName
            .toLowerCase()
            .indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    // 键值配对
    status(val) {
      var str = this.stateOptions.find(function(item) {
        return item.id == val;
      });
      if (str) return str.title;
    },
    status_consult(val){
      let str = this.consultList.find(function(item){
        return item.id == val;
      })
      if(str) return str.title;
    },
    // 键值配对
    status2(val) {
      var str = this.cateList2.find(function(item) {
        return item.id == val;
      });
      if (str) return str.categoryName;
    },
    handleAvatarSuccess(res, file) {
      if (res.code == 200) {
        this.formData.businessLicense = res.url;
        console.log(this.formData.businessLicense);
        this.$message.success(`上传成功`);
      }
    },
    // 获取创建时间
    createTime(e) {
      console.log(e);
    },
    // 新增修改的方法
    submitForm() {
      this.$refs["formData"].validate(valid => {
        if (valid) {
          if (this.title666 == "新增") {
            company_add(this.formData).then(res => {
              console.log(res);
              if (res.code == 200) {
                this.$message.success(`新增成功`);
                this.dialogVisible = false;
                this.getData00();
              }
            });
          } else {
            company_update(this.formData).then(res => {
              if (res.code == 200) {
                this.$message.success(`修改成功`);
                this.dialogVisible = false;
                this.uploading = false;
                this.getData00();
              }
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 打开搜索
    openSearch() {
      this.openFlag = !this.openFlag;
    },
    // 重置搜索框
    cancelData() {
      this.params={
        pageNum: 1,
        pageSize: 10,
        state: 3,
        position: 1
      }
      this.resetForm("params");
      this.getData00();
    },
    handleAdd() {
      this.formData = {
        businessLicense: ""
      };
      this.dialogVisible = true;
      this.title666 = "新增";
    },
    handleEdit(index, row , ind) {
      this.ind = ind;
      let rowCopy = JSON.parse(JSON.stringify(row));
      this.formData = rowCopy;
      this.formData.businessLicense = JSON.parse(row.businessLicense);
      this.dialogVisible = true;
      this.title666 = "查看";
    },
    handleExamine(index, row) {
      this.formData = row;
      this.dialogVisible = true;
      this.title666 = "审核";
    },
    closeDialog() {
      this.dialogVisible = false;
    },
    // 删除操作
    handleSelectionChange(val) {
      this.ids = val.map(item => item.id);
      this.single = val.length != 1;
      this.multiple = !val.length;
    },
    // 批量删除
    handleDelete(row) {
      const id = row.id || this.ids;
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return company_delete(id);
        })
        .then(() => {
          this.getData00();
          this.msgSuccess("删除成功");
        })
        .catch(function() {});
    },

    // 触发搜索按钮
    search() {
      this.$set(this.params, "pageNum", 1);
      this.paramsFlag = 0;
      this.getData00();
    },
    // 分页导航
    handlePageChange(val) {
      this.$set(this.params, "pageNum", val);
      this.getData00();
    }
  }
};
</script>

<style scoped>
.resource {
  padding: 20px 30px;
}
.container {
  margin-top: 20px;
}
.handle-box {
  margin-bottom: 10px;
}

.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}
.yellow {
  color: #f57506;
}
.green {
  color: green;
  cursor: pointer;
}
.blue2 {
  color: #409eff;
}
.blue {
  color: #409eff;
  cursor: pointer;
  text-decoration: underline;
}
.mr10 {
  margin-right: 10px;
}

.searchForm .el-form-item--mini.el-form-item,
.searchForm .el-form-item--small.el-form-item {
  margin-bottom: 1px;
}
.study_pic {
  display: block;
  width: 100px;
  height: 85px;
  margin: auto;
  /* border-radius: 50%; */
}
.avatar {
  display: inline-block;
  margin-right: 10px;
}
.avatar img {
  width: 200px;
}
.progress_box {
  width: 100%;
  display: flex;
  box-sizing: border-box;
  padding: 10px 30px;
  margin: 0 auto;
  justify-content: space-between;
  background-color: #fff;
  /* align-items: center; */
}
.progress_box .left {
  width: 15%;
  color: #888;
  font-size: 14px;
}
.progress_box .left_c {
  width: 15%;
  color: #444;
  font-weight: bold;
  font-size: 14px;
}
.progress_box .right {
  width: 75%;
  color: #888;
  font-size: 14px;
}
.progress_box .right_c {
  width: 75%;
  color: #444;
  font-size: 14px;
}
.progress_box .center {
  width: 10%;
  text-align: center;
  line-height: 1;
  /* display: flex;
  align-items: center; */
}
</style>
